//
//  AppTVListTableCell.m
//  classicFilms
//
//  Created by 刘继丹 on 17/3/14.
//  Copyright © 2017年 Stefan Arn. All rights reserved.
//

#import "AppTVListTableCell.h"
#import <Masonry.h>

@interface AppTVListTableCell()

@property(nonatomic, strong) UILabel *mTitleLabel;

@property(nonatomic, strong) AppTVTopLoopView *mAppTVTopLoopView;

@end

@implementation AppTVListTableCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
        self.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:self.mTitleLabel];
        [self.contentView addSubview:self.mAppTVTopLoopView];
        
        [_mTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(90);
            make.top.mas_equalTo(self.contentView.mas_top).with.offset(70);
            make.height.mas_equalTo(26);
        }];
        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _mAppTVTopLoopView.frame = CGRectMake(0, 106, self.frame.size.width, self.frame.size.height-106);
}

-(void)setItemArr:(NSArray *)itemArr{
    if (_itemArr != itemArr) {
        _itemArr = itemArr;
    }
    _mAppTVTopLoopView.appleTVType = _appleTVType;
    _mAppTVTopLoopView.imageArr = _itemArr;
}

-(void)setTitleStr:(NSString *)titleStr{
    if (_titleStr != titleStr) {
        _titleStr = titleStr;
    }
    _mTitleLabel.text = _titleStr;
}

-(UILabel *)mTitleLabel{
    if (!_mTitleLabel) {
        _mTitleLabel = [[UILabel alloc]init];
        _mTitleLabel.textColor = [UIColor whiteColor];
        _mTitleLabel.font = [UIFont systemFontOfSize:26];
    }
    return _mTitleLabel;
}

-(AppTVTopLoopView *)mAppTVTopLoopView{
    if (!_mAppTVTopLoopView) {
        _mAppTVTopLoopView = [[AppTVTopLoopView alloc]initWithFrame:CGRectMake(0, 140, KVIEW_W, 280) type:AppTVLoopViewType_cell];
        __weak typeof(self) weakself = self;
        _mAppTVTopLoopView.imageSelectBlock = ^(NSInteger selectIndex){
            if (weakself.imageSelectBlock) {
                weakself.imageSelectBlock(selectIndex);
            }
        };
    }
    return _mAppTVTopLoopView;
}



@end
